import React from 'react';
import { Button, Checkbox, Form, Input } from 'antd';
import instance from '../../axios/instance';
import JSEncrypt from 'jsencrypt';

const App = () => {
  const publicKey = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuQd3gESx7VdIyRYUWjmjg61VIgUK6F45hClmqUMZ7xNiT5rlLM6e78osMvBF/yP7cVm7pK+NMCDWoVS1/AETpxJYqUlIC77ZAU8/MnP96IupnJL87vqhPcpdv7+VqLM38ls++yuD/F/HSoOQTv/leJh+dgE/4EYAJjOWFAbYfXwIDAQAB`;
  const encryptor = new JSEncrypt();
  encryptor.setPublicKey(publicKey);
  const originalData = '123456';
  const encryptedData = encryptor.encrypt(originalData);


  const onFinish = values => {
    console.log('Success:', values);
    instance.post('/api/health/user/v1/login').then(res => {
      console.log('res', res)
    })
  };

  return (
    <div style={{ width: '200px' }}>
      <Form
        name="basic"
        labelCol={{ span: 8 }}
        wrapperCol={{ span: 16 }}
        style={{ maxWidth: 600 }}
        initialValues={{ remember: true }}
        onFinish={onFinish}
        autoComplete="off"
      >
        <Form.Item
          label="邮箱"
          name="email"
          rules={[{ required: true, message: 'Please input your username!' }]}
          
        >
          <div style={{ display: 'flex', alignItems: 'center' }}>
            <Input />
            <Button>获取验证码</Button>
          </div>
        </Form.Item>

        <Form.Item
          label="验证码"
          name="code"
          rules={[{ required: true, message: 'Please input your password!' }]}
        >
          <Input />
        </Form.Item>

        <Form.Item
          label="密码"
          name="pwd1"
          rules={[{ required: true, message: 'Please input your password!' }]}
        >
          <Input.Password />
        </Form.Item>

        <Form.Item
          label="确认密码"
          name="pwd2"
          rules={[{ required: true, message: 'Please input your password!' }]}
        >
          <Input.Password />
        </Form.Item>

        <Form.Item label={null}>
          <Button type="primary" htmlType="submit">
            注册
          </Button>
        </Form.Item>
      </Form>
    </div>
  )
};
export default App;